package com.bitcoin.scheduler.repository;

import com.bitcoin.scheduler.domain.blockcc.KLineBlockCC;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;
import java.util.Date;

public interface KLineBlockCCDao extends JpaRepository<KLineBlockCC, String> {
    void deleteByMarketAndSymbol(String market, String symbol);

    @Query("DELETE FROM KLineBlockCC WHERE market=:market AND symbol=:symbol AND priceTime >=:startDate AND priceTime<=:endDate")
    @Modifying
    @Transactional
    void removeByMarketAndSymbolAndPriceTimeBetween(@Param("market") String market, @Param("symbol") String symbol, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
}
